package com.wbao.dianniu.update;

import java.util.ArrayList;
import java.util.List;

import com.wbao.dianniu.data.ActivityData;

/**
 * 我发布的数据-状态修改管理类
 * 
 * @author yejianjun
 *
 */
public class ReleaseDataManager {

	private List<IReleaseDelListener> mList;
	private static ReleaseDataManager instance;
	public interface IReleaseDelListener{
		public void removeOneData(int activityId);
		public void modifyOneData(int activityId, ActivityData data);
	}
	
	public static ReleaseDataManager getInstance(){
		if(null == instance){
			instance = new ReleaseDataManager();
		}
		return instance;
	}
	
	private ReleaseDataManager() {
		mList = new ArrayList<IReleaseDelListener>();
	}
	
	public void delete(int activityId){
		if(null == mList)
			return;
		for (int i = 0; i < mList.size(); i++) {
			mList.get(i).removeOneData(activityId);
		}
	}
	
	public void addListener(IReleaseDelListener list){
		if(null == mList){
			mList = new ArrayList<IReleaseDelListener>();
		}
		mList.add(list);
	}
	
	public void removeListener(IReleaseDelListener list){
		if(null != mList){
			mList.remove(list);
		}
	}
	
	public void modifyOneData(int activityId, ActivityData data) {
		if (null == mList)
			return;
		for (int i = 0; i < mList.size(); i++) {
			mList.get(i).modifyOneData(activityId, data);
		}
	}
	
}
